package com.qf.jwtresourceserver.controller;


import com.qf.jwtresourceserver.pojo.UserInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.security.core.Authentication;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/userinfo")
public class UserInfoController {

    private static Logger logger = LoggerFactory.getLogger(UserInfoController.class);

    @RequestMapping
    public Object userInfo(Authentication authentication) {
        logger.info(authentication.getName() + ";;" + authentication.getPrincipal());

        String principal = authentication.getPrincipal().toString();
        UserInfo userInfo = new UserInfo();
        userInfo.setGender("女");

        if("c".equals(principal)) {
            userInfo.setNickyname("李小璐");
            userInfo.setProfile("http://localhost/lxl.jpg");
        }

        if("a".equals(principal)) {
            userInfo.setNickyname("柳岩");
            userInfo.setProfile("http://localhost/ly.jpg");
        }
        return userInfo;
    }
}